package com.health.mapp.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.health.db.model.PatientShortInfo;
import com.health.db.service.user.IPatientShortInfoService;
import com.health.mapp.bean.Header;
import com.health.mapp.bean.QueryPatientByCardIdReq;
import com.health.mapp.bean.QueryPatientByCardIdResp;
import com.health.mapp.utils.Response;
import com.health.mapp.utils.ResultCode;

/**
 * 按照就诊卡号查询用户信息
 * @author yuchong
 */
public class QueryPatientByCardIdImpl implements ActionInterface{

	@Autowired
	IPatientShortInfoService patientShortInfoService;
	
    @Override
    public Response execute(Header header, Object reqBean) throws Exception {

    	QueryPatientByCardIdReq req = (QueryPatientByCardIdReq) reqBean;
    	QueryPatientByCardIdResp _resp = new QueryPatientByCardIdResp();

        if (StringUtils.isEmpty(req.getMedicalCardNo()))
        {
            _resp.setErrorCode(ResultCode.OPERATION_LAKE_PARAMETER_ERROR);
            _resp.setErrorMsg(ResultCode.OPERATION_LAKE_PARAMETER_ERROR_NOTE);
            return _resp;
        }
		
       PatientShortInfo patient=patientShortInfoService.selectByMedicalCardNo(req.getMedicalCardNo());
       
       _resp.setPatient(patient);
	   _resp.setErrorCode(ResultCode.OPERATION_SUCCESS);
	   _resp.setErrorMsg(ResultCode.OPERATION_SUCCESS_NOTE);
       return _resp;
    }


}
